package com.czkj.hwz.decorate.Activity;

import android.content.Intent;
import android.os.Build;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.czkj.hwz.decorate.R;
import com.king.base.BaseActivity;

public class SelectActivity extends BaseActivity {
    private ListView lv;
    private String[] cityArrays;
    @Override
    public void initUI() {
        if (Build.VERSION.SDK_INT >= 21){
            Window window = getWindow();
            //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            //设置状态栏颜色
            window.setStatusBarColor(getResources().getColor(R.color.yellow));
        }
        setContentView(R.layout.activity_select);
        getSupportActionBar().hide();
        lv=findView(R.id.lv);

    }

    @Override
    public void initData() {
        cityArrays=new String[] {"淮安","连云港","南京","上海"};
        ArrayAdapter adapter=new ArrayAdapter(context,android.R.layout.simple_list_item_1,cityArrays);
        lv.setAdapter(adapter);
    }

    @Override
    public void addListeners() {
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String cityName=cityArrays[position];
                Intent intent=new Intent();
                intent.putExtra("cityName",cityName);
                setResult(2,intent);
                finish();
            }
        });

    }
    public void OnClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
